<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信助手网页版</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            color: #333;
        }
        
        .container {
            max-width: 400px;
            margin: 20px auto;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        .header {
            background-color: #07C160;
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 18px;
        }
        
        .login-container {
            padding: 20px;
        }
        
        .login-title {
            text-align: center;
            margin-bottom: 20px;
            font-size: 22px;
            color: #333;
        }
        
        .login-methods {
            display: flex;
            justify-content: space-around;
            margin-bottom: 20px;
        }
        
        .login-method {
            padding: 10px 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .login-method.active {
            border-color: #07C160;
            background-color: #f0fff4;
            color: #07C160;
        }
        
        .login-form {
            margin-bottom: 20px;
        }
        
        .form-group {
            margin-bottom: 15px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-size: 14px;
        }
        
        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        
        .btn {
            width: 100%;
            padding: 12px;
            background-color: #07C160;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s;
        }
        
        .btn:hover {
            background-color: #06ae56;
        }
        
        .chat-container {
            display: flex;
            height: 600px;
        }
        
        .sidebar {
            width: 35%;
            background-color: #2E3238;
            color: white;
            overflow-y: auto;
        }
        
        .user-info {
            padding: 15px;
            background-color: #282C34;
            display: flex;
            align-items: center;
        }
        
        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
            background-color: #07C160;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
        }
        
        .contacts {
            padding: 10px 0;
        }
        
        .contact {
            padding: 10px 15px;
            display: flex;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        
        .contact:hover {
            background-color: #3A3F47;
        }
        
        .contact.active {
            background-color: #07C160;
        }
        
        .contact-avatar {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            margin-right: 10px;
            background-color: #4CAF50;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .chat-area {
            width: 65%;
            display: flex;
            flex-direction: column;
        }
        
        .chat-header {
            padding: 15px;
            border-bottom: 1px solid #eee;
            font-weight: bold;
        }
        
        .messages {
            flex: 1;
            padding: 15px;
            overflow-y: auto;
            background-color: #f5f5f5;
        }
        
        .message {
            margin-bottom: 15px;
            display: flex;
        }
        
        .message.self {
            justify-content: flex-end;
        }
        
        .message-content {
            max-width: 70%;
            padding: 10px 15px;
            border-radius: 5px;
            position: relative;
        }
        
        .message.other .message-content {
            background-color: white;
            border: 1px solid #e0e0e0;
        }
        
        .message.self .message-content {
            background-color: #95EC69;
        }
        
        .message-sender {
            font-size: 12px;
            color: #888;
            margin-bottom: 5px;
        }
        
        .message-time {
            font-size: 10px;
            color: #aaa;
            text-align: right;
            margin-top: 5px;
        }
        
        .input-area {
            padding: 15px;
            border-top: 1px solid #eee;
            display: flex;
        }
        
        .input-area input {
            flex: 1;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            margin-right: 10px;
        }
        
        .send-btn {
            padding: 10px 20px;
            background-color: #07C160;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        
        .logout-btn {
            display: block;
            width: 100%;
            padding: 10px;
            background-color: #f0f0f0;
            color: #666;
            border: none;
            border-top: 1px solid #e0e0e0;
            cursor: pointer;
            text-align: center;
        }
        
        .logout-btn:hover {
            background-color: #e0e0e0;
        }
        
        .hidden {
            display: none;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- 登录界面 -->
        <div class="container" v-if="!isLoggedIn">
            <div class="header">微信助手</div>
            <div class="login-container">
                <h2 class="login-title">登录微信助手</h2>
                
                <!-- 登录方式选择 -->
                <div class="login-methods">
                    <div class="login-method" 
                         :class="{active: loginMethod === 'password'}" 
                         @click="selectLoginMethod('password')">
                        密码登录
                    </div>
                    <div class="login-method" 
                         :class="{active: loginMethod === 'qr'}" 
                         @click="selectLoginMethod('qr')">
                        扫码登录
                    </div>
                </div>
                
                <!-- 密码登录表单 -->
                <div class="login-form" v-if="loginMethod === 'password'">
                    <div class="form-group">
                        <label for="username">用户名/手机号</label>
                        <input type="text" id="username" v-model="username" placeholder="请输入用户名或手机号">
                    </div>
                    <div class="form-group">
                        <label for="password">密码</label>
                        <input type="password" id="password" v-model="password" placeholder="请输入密码">
                    </div>
                </div>
                
                <!-- 扫码登录界面 -->
                <div class="login-form" v-if="loginMethod === 'qr'">
                    <div style="text-align: center; padding: 20px;">
                        <p>请使用微信扫描下方二维码登录</p >
                        <div style="width: 200px; height: 200px; background-color: #f0f0f0; margin: 20px auto; display: flex; align-items: center; justify-content: center;">
                            [二维码区域]
                        </div>
                        <p>扫描二维码登录微信助手</p >
                    </div>
                </div>
                
                <button class="btn" @click="login">登录</button>
            </div>
        </div>
        
        <!-- 聊天界面 -->
        <div class="container" v-if="isLoggedIn">
            <div class="chat-container">
                <!-- 侧边栏 -->
                <div class="sidebar">
                    <!-- 个人信息 -->
                    <div class="user-info">
                        <div class="avatar">
                            {{ userInfo.name.charAt(0) }}
                        </div>
                        <div>
                            <div>{{ userInfo.name }}</div>
                            <div style="font-size: 12px; color: #aaa;">在线</div>
                        </div>
                    </div>
                    
                    <!-- 联系人列表 -->
                    <div class="contacts">
                        <div class="contact" 
                             v-for="contact in contacts" 
                             :key="contact.id"
                             :class="{active: currentContact.id === contact.id}"
                             @click="selectContact(contact)">
                            <div class="contact-avatar">
                                {{ contact.name.charAt(0) }}
                            </div>
                            <div>
                                <div>{{ contact.name }}</div>
                                <div style="font-size: 12px; color: #aaa;">{{ contact.lastMessage }}</div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 聊天区域 -->
                <div class="chat-area">
                    <div class="chat-header">
                        {{ currentContact.name }}
                    </div>
                    
                    <!-- 消息列表 -->
                    <div class="messages">
                        <div class="message" 
                             :class="message.sender === 'self' ? 'self' : 'other'" 
                             v-for="message in currentMessages" 
                             :key="message.id">
                            <div class="message-content">
                                <div class="message-sender" v-if="message.sender !== 'self'">
                                    {{ message.senderName }}
                                </div>
                                <div>{{ message.content }}</div>
                                <div class="message-time">{{ message.time }}</div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 输入区域 -->
                    <div class="input-area">
                        <input type="text" v-model="newMessage" placeholder="输入消息..." @keyup.enter="sendMessage">
                        <button class="send-btn" @click="sendMessage">发送</button>
                    </div>
                </div>
            </div>
            
            <button class="logout-btn" @click="logout">退出登录</button>
        </div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                // 登录状态
                isLoggedIn: false,
                
                // 登录方式
                loginMethod: 'password',
                
                // 登录表单数据
                username: '',
                password: '',
                
                // 用户信息
                userInfo: {
                    id: 1,
                    name: '张三',
                    avatar: ''
                },
                
                // 联系人列表
                contacts: [
                    { id: 2, name: '李四', lastMessage: '你好，最近怎么样？' },
                    { id: 3, name: '王五', lastMessage: '明天开会别忘了' },
                    { id: 4, name: '赵六', lastMessage: '项目进展如何？' },
                    { id: 5, name: '钱七', lastMessage: '晚上一起吃饭吗？' }
                ],
                
                // 当前选中的联系人
                currentContact: {},
                
                // 消息列表
                messages: {
                    2: [
                        { id: 1, sender: 'other', senderName: '李四', content: '你好，最近怎么样？', time: '10:30' },
                        { id: 2, sender: 'self', content: '还不错，你呢？', time: '10:32' },
                        { id: 3, sender: 'other', senderName: '李四', content: '我也挺好的，有空聚聚？', time: '10:33' }
                    ],
                    3: [
                        { id: 1, sender: 'other', senderName: '王五', content: '明天开会别忘了', time: '09:15' },
                        { id: 2, sender: 'self', content: '好的，几点？', time: '09:16' },
                        { id: 3, sender: 'other', senderName: '王五', content: '上午10点，会议室A', time: '09:17' }
                    ],
                    4: [
                        { id: 1, sender: 'other', senderName: '赵六', content: '项目进展如何？', time: '昨天' },
                        { id: 2, sender: 'self', content: '已经完成80%了', time: '昨天' }
                    ],
                    5: [
                        { id: 1, sender: 'other', senderName: '钱七', content: '晚上一起吃饭吗？', time: '15:20' }
                    ]
                },
                
                // 新消息
                newMessage: ''
            },
            computed: {
                // 当前联系人的消息列表
                currentMessages() {
                    if (this.currentContact.id) {
                        return this.messages[this.currentContact.id] || [];
                    }
                    return [];
                }
            },
            methods: {
                // 选择登录方式
                selectLoginMethod(method) {
                    this.loginMethod = method;
                },
                
                // 登录
                login() {
                    if (this.loginMethod === 'password') {
                        if (!this.username || !this.password) {
                            alert('请输入用户名和密码');
                            return;
                        }
                    }
                    
                    // 模拟登录成功
                    this.isLoggedIn = true;
                    
                    // 默认选择第一个联系人
                    if (this.contacts.length > 0) {
                        this.currentContact = this.contacts[0];
                    }
                },
                
                // 退出登录
                logout() {
                    this.isLoggedIn = false;
                    this.username = '';
                    this.password = '';
                },
                
                // 选择联系人
                selectContact(contact) {
                    this.currentContact = contact;
                },
                
                // 发送消息
                sendMessage() {
                    if (!this.newMessage.trim()) return;
                    
                    const contactId = this.currentContact.id;
                    if (!this.messages[contactId]) {
                        this.messages[contactId] = [];
                    }
                    
                    // 添加新消息
                    const newMsg = {
                        id: this.messages[contactId].length + 1,
                        sender: 'self',
                        content: this.newMessage,
                        time: this.getCurrentTime()
                     };
                    
                    this.messages[contactId].push(newMsg);
                    
                    // 更新联系人的最后一条消息
                    this.currentContact.lastMessage = this.newMessage;
                    
                    // 清空输入框
                    this.newMessage = '';
                    
                    // 模拟对方回复
                    setTimeout(() => {
                        const replyMsg = {
                            id: this.messages[contactId].length + 1,
                            sender: 'other',
                            senderName: this.currentContact.name,
                            content: '收到你的消息了',
                            time: this.getCurrentTime()
                        };
                        
                        this.messages[contactId].push(replyMsg);
                        this.currentContact.lastMessage = '收到你的消息了';
                    }, 1000);
                },
                
                // 获取当前时间
                getCurrentTime() {
                    const now = new Date();
                    return `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
                }
            },
            mounted() {
                // 初始化当前联系人
                if (this.contacts.length > 0) {
                    this.currentContact = this.contacts[0];
                }
            }
        });
    </script>
</body>
</html>
                     